import java.util.Scanner;

public class study {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        /*
        int input = in.nextInt();
        System.out.println(fib(input));
        System.out.println(sumMax(1,2));
        System.out.println(sumMax(1.0, 2.5, 3.5));
        System.out.println(fac(5));
        System.out.println(add(10));
        print(1451);
        System.out.println(fib2(6));

         */
        System.out.println(sum(15897));
    }

    public static int fib(int n) {
        if (n == 1 || n == 2) {
            return 1;
        } else {
            return fib(n - 1) + fib(n - 2);
        }
    }

    public static int fib2(int n) {
        if(n == 1 || n == 2) {
            return 1;
        }else {
            int f1 = 1;
            int f2 = 1;
            int f3 = -1;
            for (int i = 3; i <= n; i++) {
                f3 = f1 + f2;
                f1 = f2;
                f2 = f3;
            }
            return f3;
        }
    }

    public static int sumMax(int a, int b) {
        return a + b;
    }

    public static double sumMax(double a, double b, double c) {
        return a + b + c;
    }

    public static int fac(int n) {
        if(n == 1) {
            return 1;
        }else {
            return n * fac(n - 1);
        }
    }

    public static int add(int n) {
        if(n == 1) {
            return 1;
        }else {
            return n + add(n - 1);
        }
    }

    public static void print(int n) {
        if(n < 10) {
            System.out.print(n + " ");
        }else {
            print(n/10);
            System.out.print(n%10 + " ");
        }
    }

    public static int sum(int n) {
        if(n < 10) {
            return n;
        }else {
            return (n % 10) + sum(n / 10);
        }
    }
}

